package com.es; /**
 * 描述:
 * es-jsp-
 *
 * @author Derek
 * 创建时间：2022-04-28 9:48
 */

import com.es.bean.Employee;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@WebServlet(name = "ListServlet", value = "/list")
public class ListServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        List<Employee> emps = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            Employee employee = new Employee();
            employee.setId(i+1);
            employee.setName("小黑"+employee.getId()+"号");
            emps.add(employee);
        }

        request.setAttribute("emps",emps);
        request.getRequestDispatcher("list.jsp").forward(request,response);
    }


}
